﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace ZGEDrySaltery.Web.cart
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int CARTID=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(CARTID);
				}
			}
		}
			
	private void ShowInfo(int CARTID)
	{
		ZGEDrySaltery.BLL.cart bll=new ZGEDrySaltery.BLL.cart();
		ZGEDrySaltery.Model.cart model=bll.GetModel(CARTID);
		this.lblCARTID.Text=model.CARTID.ToString();
		this.txtUSERID.Text=model.USERID.ToString();
		this.txtOFFERID.Text=model.OFFERID.ToString();
		this.txtCOUNT.Text=model.COUNT.ToString();
		this.txtCOMPANYID.Text=model.COMPANYID.ToString();
		this.txtINSERTTIME.Text=model.INSERTTIME.ToString();
		this.txtMODIFYTIME.Text=model.MODIFYTIME.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtUSERID.Text))
			{
				strErr+="USERID格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtOFFERID.Text))
			{
				strErr+="OFFERID格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtCOUNT.Text))
			{
				strErr+="COUNT格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtCOMPANYID.Text))
			{
				strErr+="COMPANYID格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtINSERTTIME.Text))
			{
				strErr+="INSERTTIME格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtMODIFYTIME.Text))
			{
				strErr+="MODIFYTIME格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int CARTID=int.Parse(this.lblCARTID.Text);
			int USERID=int.Parse(this.txtUSERID.Text);
			int OFFERID=int.Parse(this.txtOFFERID.Text);
			int COUNT=int.Parse(this.txtCOUNT.Text);
			int COMPANYID=int.Parse(this.txtCOMPANYID.Text);
			DateTime INSERTTIME=DateTime.Parse(this.txtINSERTTIME.Text);
			DateTime MODIFYTIME=DateTime.Parse(this.txtMODIFYTIME.Text);


			ZGEDrySaltery.Model.cart model=new ZGEDrySaltery.Model.cart();
			model.CARTID=CARTID;
			model.USERID=USERID;
			model.OFFERID=OFFERID;
			model.COUNT=COUNT;
			model.COMPANYID=COMPANYID;
			model.INSERTTIME=INSERTTIME;
			model.MODIFYTIME=MODIFYTIME;

			ZGEDrySaltery.BLL.cart bll=new ZGEDrySaltery.BLL.cart();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
